import request from '@/utils/request'

// 生成习题
export function generateHomework(data) {
  return request({
    url: '/api/teaching/generate-exercises',
    method: 'post',
    data
  })
}

// 保存习题到历史记录
export function saveHomework(data) {
  return request({
    url: '/api/homework/save',
    method: 'post',
    data
  })
}

// 获取历史记录列表
export function getHomeworkHistory(params) {
  return request({
    url: '/api/homework/history',
    method: 'get',
    params
  })
}

// 删除历史记录
export function deleteHomework(id) {
  return request({
    url: `/api/homework/${id}`,
    method: 'delete'
  })
}

// AI对话生成习题
export function chatGenerateHomework(data) {
  return request({
    url: '/api/homework/chat',
    method: 'post',
    data
  })
}

// 获取教材章节列表
export function getTextbookChapters(data) {
  return request({
    url: '/api/homework/textbook/chapters',
    method: 'get',
    params: data
  })
}

// 生成课后习题
export function generateAfterClassHomework(data) {
  return request({
    url: '/api/homework/after-class/generate',
    method: 'post',
    data
  })
}

// 保存课后习题
export function saveAfterClassHomework(data) {
  return request({
    url: '/api/homework/after-class/save',
    method: 'post',
    data
  })
}

// 获取课后习题历史记录
export function getAfterClassHistory(params) {
  return request({
    url: '/api/homework/after-class/history',
    method: 'get',
    params
  })
}

// 删除课后习题记录
export function deleteAfterClassHomework(id) {
  return request({
    url: `/api/homework/after-class/${id}`,
    method: 'delete'
  })
}

// 获取热点考题列表
export function getHotQuestions(params) {
  return request({
    url: '/api/homework/hot',
    method: 'get',
    params
  })
}

// 获取高频错题列表
export function getFrequentMistakes(params) {
  return request({
    url: '/api/homework/mistakes',
    method: 'get',
    params
  })
}

// 获取习题详情
export function getHomeworkDetail(id) {
  return request({
    url: `/api/homework/${id}`,
    method: 'get'
  })
}

// AI对话接口
export function chatWithAI(data) {
  return request({
    url: '/api/chat',
    method: 'post',
    data
  })
} 